﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.MEP.Electric.CableLay
{
	public partial class CableListExportForm : System.Windows.Forms.Form
	{
		public CableListExportForm(CableLayMainForm parentForm)
		{
			this.InitializeComponent();
		}

		private void CableListExportForm_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
			if (this.cbPaging.Checked)
			{
				this.lbRowCount.Enabled = true;
				this.tbRowCount.Enabled = true;
				return;
			}
			this.lbRowCount.Enabled = false;
			this.tbRowCount.Enabled = false;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.m_paging = this.cbPaging.Checked;
			try
			{
				if (this.m_paging)
				{
					this.m_rowCount = int.Parse(this.tbRowCount.Text);
					if (this.m_rowCount < 1)
					{
						throw new Exception();
					}
				}
			}
			catch
			{
				MessageBox.Show("行数应为正整数！", "盈建科提示");
				this.tbRowCount.SelectAll();
				this.tbRowCount.Focus();
				base.DialogResult = DialogResult.None;
			}
		}

		private void cbPaging_CheckedChanged(object sender, EventArgs e)
		{
			if (this.cbPaging.Checked)
			{
				this.lbRowCount.Enabled = true;
				this.tbRowCount.Enabled = true;
				return;
			}
			this.lbRowCount.Enabled = false;
			this.tbRowCount.Enabled = false;
		}

		private void CableListExportForm_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}

		public bool m_paging;

		public int m_rowCount = -1;
	}
}
